home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_gen_fallingdebris.cog < prev    next >
Text File  |  1999-11-15  |  4KB  |  112 lines

  1. # Jones 3D Cog Script
  2. #
  3. # gen_FallingDebris.cog
  4. #
  5. # debris = place a ghost object in the center of your room and put it near the ceiling.
  6. # clutter = place a ghost object in the center of the room at floor level.
  7. #
  8. # turn on this cog from another cog with SendMessage(cogname, user0);
  9. # turn off this cog from another cog with SendMessage(cogname, user1);
  10. #
  11. # [TRM]
  12. #
  13. # (C) 1999 LucasArts Entertainment Co. All Rights Reserved
  14. # ========================================================================================
  15.  
  16. symbols
  17.  
  18.     message     user0
  19.     message     user1
  20.     message     pulse
  21.     message     timer
  22.     
  23.     thing       debris              # the junk that falls
  24.     thing       clutter             # the junk left on the floor
  25.     
  26.     thing       rocks               local
  27.     thing       scraps              local
  28.     
  29.     sound       sndFalling=gen_falling_debris_c.wav     local   # falling rocks
  30.     
  31.     template    debris0=stnshrapa_nc_ns         local   # large debris
  32.     template    debris1=stnshrapbm_nc_ns        local   # medium debris
  33.     template    debris2=stnshrapcs_nc_ns        local   # small debris
  34.     template    clutter0=stnshrpa               local   # large clutter
  35.     template    clutter1=stnshrpbm              local   # medium clutter
  36.     template    clutter2=stnshrpcs              local   # small clutter
  37.     
  38.     vector      vecPos              local
  39.     vector      rocksVel            local
  40.     
  41.     int         deb                 local
  42.     int         clut                local
  43.     int         sound1              local
  44.     
  45.     int         numDebris           # how many falling particles to generate w/each pulse.
  46.     int         numClutter          # number of clutter scraps to leave lying on the floor
  47.                                     # set numClutter to 0 for none.
  48.     
  49.     flex        xVal                # x = width of room
  50.     flex        yVal                # y = length of room
  51.     flex        pulseTime=0.25      # duh
  52.     flex        minSndDist          # min distance for debris sfx
  53.     flex        maxSndDist          # max distance for debris sfx
  54.     flex        sndVol              # duh
  55.     
  56. end
  57.  
  58. # ========================================================================================
  59.  
  60. code
  61.  
  62. user0:
  63.  
  64.     SetPulse(pulseTime);
  65.     SetTimer(pulseTime+1.0);
  66.     sound1 = PlaySoundThing(sndFalling, debris, sndVol, minSndDist, maxSndDist, 0x81);
  67.     return;
  68.     
  69. # ========================================================================================
  70.  
  71. user1:
  72.  
  73.     SetPulse(0.0);
  74.     StopSound(sound1, 0.0);
  75.     return;
  76.  
  77. # ========================================================================================
  78.  
  79. pulse:
  80.     
  81.     SetPulse(0.0);
  82.     for(deb=0; deb<numDebris; deb=deb+1)                                                                        
  83.     {                                                                                                    
  84.         vecPos = VectorSet(rand()*xVal, rand()*yVal, 0.0);
  85.         rocks = CreateThingAtPos(debris0[RandBetween(0, 2)], GetThingSector(debris), VectorAdd(GetThingPos(debris), VectorAdd('-0.25 -0.25 0.0', vecPos)), '0 0 0');
  86.         rocksVel = VectorSet(0, 0, 0.01);
  87.         SetThingVel(rocks, VectorScale(rocksVel, 0.7));
  88.     }
  89.     SetPulse(pulseTime);
  90.     
  91.     return;
  92.  
  93. # ========================================================================================
  94.  
  95. timer:
  96.  
  97.     if(numClutter == 0) return;
  98.     
  99.     for(clut=0; clut<numClutter; clut=clut+1)                                                                        
  100.     {                                                                                                    
  101.         vecPos = VectorSet(rand()*xVal, rand()*yVal, 0.0);
  102.         scraps = CreateThingAtPos(clutter0[RandBetween(0, 2)], GetThingSector(debris), VectorAdd(GetThingPos(clutter), VectorAdd('-0.25 -0.25 0.0', vecPos)), '0 0 0');
  103.         Sleep(rand()+0.5);
  104.     }
  105.     
  106.     return;
  107.  
  108. # ========================================================================================
  109.  
  110. end
  111.  
  112.